package demo2;

import java.io.*;

public class Test {
    public static void main(String[] args)throws Exception {
        OutputStream os = new FileOutputStream("d:/1.txt");
        BufferedOutputStream bo = new BufferedOutputStream(os);
//        os.write("我是hello".getBytes());
        bo.write("我是hello".getBytes());
        bo.flush();
        os.close();
    }

    public static void readbyte(String[] args)throws Exception {
        InputStream is = new FileInputStream("d:/1.txt");
        byte[]data = new byte[100];
        int len = is.read(data);
        System.out.println(new String(data,0,len));
        is.close();
    }

    public static void writechar(String[] args)throws Exception {
        Writer w = new FileWriter("d:/1.txt",true);
        w.write("我是01");
        w.close();
    }

    public static void readchar(String[] args) throws Exception{
        Reader r = new FileReader("d:/1.txt");
        char[]arr = new char[100];
        int len = r.read(arr);
        System.out.println(new String(arr,0,len));
    }


}
